package person.bangbang.im.Androidgin.Loopback;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
/**
 * a example loopback IM Thread which take care of send message.
 * 
 * @author bangbang.song@gmail.com
 *
 */
public class ImThread extends Thread {
	private Handler mImHandler;
	private LoopbackProtocol mProtocol;
	public ImThread(LoopbackProtocol p,Handler m) {
		// this is explicit in debug mode in eclipse.
		super("Loopback Protocol fake IM client");
		mImHandler = m;
		mProtocol = p;
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub
		Message msg = Message.obtain();
		msg.what = ImHandler.CODE_RCVD_MSG;
		msg.obj = new String("hi bangbang.S, I'm from the King of Loopback");
		
		Bundle b = new Bundle();
		b.putString(ImHandler.USER_ID, mProtocol.getProtocolID() + ':' + mProtocol.getUserName());
		msg.setData(b);
		
		mImHandler.sendMessageDelayed(msg, 3*100);
	}
}
